const request = require('@/utils/request.js')
const constants = require('@/utils/khyConstants.js')

Page({
    data: {
      dataList: [],
      serviceQaPhone: ''
    },

    onLoad() {
        this.getPageData();
        this.getDictData()
    },
    getPageData() {
      request.get('/HomeController/getServiceQaList').then(res => {
        if (res.data.code == constants.resultSuccessCode
          && res.data.result) {
          let data = res.data.result || []
          this.setData({
            dataList: data,
          })
        }
      })
    },

    getDictData() {
      let dictString = constants.dict.客服电话
      request.get('/HomeController/getDictData', {dictCode: dictString}).then(res => {
        if (res.data.code == constants.resultSuccessCode &&
          res.data.result) {
          let stationData = res.data.result[constants.dict.客服电话] || []
          let serviceQaPhone = []
          stationData.forEach(item => {
            serviceQaPhone = item['itemValue'] || ''
          });
          this.setData({
              serviceQaPhone: serviceQaPhone,
          })
        }
      })
    },

    detailClick(e){
      let qa = e.currentTarget.dataset.qa
      if (qa) {
        getApp().globalData.pageData[constants.page_classification] = qa
      }
        wx.navigateTo({
          url: '/pages/detail/serviceCenter/serviceCenter',
        })
    },
    callPhone() {
        wx.makePhoneCall({
         phoneNumber: '400-9121-211' //仅为示例，并非真实的电话号码
        })
    },
    /**
     * 生命周期函数--监听页面显示
     * 关闭结算订单页面时，加载onshow事件
     */
    onShow() {
        if (typeof this.getTabBar === 'function' && this.getTabBar()) {
            this.getTabBar().setData({
                tabvalue: 1
            })
        }
    },
});